<template>
  <div class="list-box">
    <toptitle :title="title"></toptitle>
    <el-container>
      <el-row :gutter="20" class="clearfix">
        <el-col :span="24" class="media" v-for="item in listArr" :key="item.id">
            <router-link :to="'/detail/'+item.id" tag="div">
              <div class="media-left" ref="leftbox">
                <img :src="item.cover.feed" alt="">
              </div>
              <div class="media-right">
                  <div class="title">{{item.title}}</div>
                  <div class="descript">{{item.description}}</div>
                  <div class="type">类型：{{item.category}}</div>
              </div>
            </router-link>
        </el-col>
      </el-row>
    </el-container>
  </div>
</template>
<script>
import toptitle from './top_title'
export default {
  data(){
    return{
      title: '',
      id: 0,
      listArr: []
    }
  },
  created(){
    this. getList();
    
  },
  mounted (){
    // this.$nextTick(()=>{
    //   this.setImgStyle()
    // })
  },
  components:{
    toptitle
  },
  methods: {
    getList: function(){
      this.id = this.$route.params.id;
      console.log(this.api.tabCont+'?'+'id='+this.id)
      this.$http.get(this.api.tabCont+'?'+'id='+this.id).then(res=>{
        var ress = res.result;
        for(var i=0; i<ress.length; i++){
            var obj = ress[i];
                this.listArr.push(obj.data.content.data);
        }
        this.title = this.listArr[0].category;
        this.$store.commit('setListData',this.listArr);
      }).catch(res=>{
        alert(res)
      })
    }
    
  }
}
</script>
<style scoped>
  .media{
    padding: 14px;
    margin-bottom: 20px;
    background-color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
  }
  .media-left{
    float: left;
    width: 130px;
    height: 110px;
    margin-right: 20px;
    overflow: hidden;
    border-radius: 4px;
    background-color: #f5f5f5; 
  }
  .media-left img{
    display: block;
    width: 100%;
    margin-top: 14px;
  }
  .media-right .title{
    font-size: 18px;
    height: 36px;
    line-height: 36px;
    overflow: hidden;
    font-weight: bold;
    color: orange;
  }
  .media-right .descript{
    font-size: 14px;
    color: #ccc;
    height: 40px;
    white-space: normal;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .media-right .type{
    line-height: 30px;
    font-size: 12px;
    color: #aaa;
  }
  .el-row{
    padding: 20px 0;
  }
</style>
